26-Search for the existence of a file.py.py


Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...


Code Snippet

filename = input('Enter a file name: ') 
try: 
  f = open (filename, "r") 
except: 
  print ('There is no file named', filename )


#Example from: http://www.annedawson.net/Python3Programs.txt

                    

Try it yourself